import peewee as pw

from apiCenter.src.lib.Model import BaseModel, DefaultCols

'''App Table'''


class DbApp(BaseModel, DefaultCols):
    id = pw.PrimaryKeyField()
    f_name = pw.CharField(max_length=100, verbose_name='应用名')
    f_code = pw.CharField(max_length=120, verbose_name='应用标识')
    b_is_sys = pw.IntegerField(default=1, verbose_name='是否系统内部,0其他,1是,2否')

    class Meta:
        table_name = 'sys_app'

'''App Api Table'''


class DbAppApi(BaseModel, DefaultCols):
    id = pw.PrimaryKeyField()
    f_name = pw.CharField(max_length=200, verbose_name='接口名')
    f_code = pw.CharField(max_length=120, verbose_name='接口标识')
    f_host = pw.CharField(max_length=400, verbose_name='接口域字段')
    f_app = pw.CharField(max_length=400, verbose_name='接口应用字段')
    f_model = pw.CharField(max_length=400, verbose_name='接口模块字段')
    f_action = pw.CharField(max_length=400, verbose_name='接口操作字段')
    n_run_counter = pw.IntegerField(default=0, verbose_name='接口总运行次数')
    j_must_field = pw.TextField(null=True, verbose_name='接口必须传参(json)')
    j_access_white_list = pw.TextField(null=True,verbose_name='接口访问白名单')
    j_access_black_list = pw.TextField(null=True,verbose_name='接口访问黑名单')

    class Meta:
        table_name = 'sys_app_api'
